<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>数据（RFC 2397）</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="wrappers.compression.html">zlib://</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="wrappers.glob.html">glob://</a></div>
 <div class="up"><a href="wrappers.html">支持的协议和封装协议</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="wrappers.data" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">data://</h1>
  <p class="refpurpose"><span class="refname">data://</span> &mdash; <span class="dc-title">数据（RFC 2397）</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-wrappers.data-description">
  <h3 class="title">说明</h3>
  <p class="para">
   自 PHP 5.2.0 起 <var class="filename">data:</var>（<a href="http://www.faqs.org/rfcs/rfc2397" class="link external">&raquo;&nbsp;RFC
   2397</a>）数据流封装器开始有效。
  </p>
 </div>


 <div class="refsect1 usage" id="refsect1-wrappers.data-usage"> 
  <h3 class="title">可选项</h3>
  <ul class="itemizedlist">
   <li class="listitem"><span class="simpara"><var class="filename">data://text/plain;base64,</var></span></li>
  </ul>
 </div>
 

 <div class="refsect1 options" id="refsect1-wrappers.data-options">
  <h3 class="title">可选项</h3>
  <p class="para">
   <table class="doctable table">
    <caption><strong>封装协议摘要</strong></caption>
    
     <thead>
      <tr>
       <th>属性</th>
       <th>支持</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>受限于 <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">allow_url_fopen</a></td>
       <td>No</td>
      </tr>

      <tr>
       <td>受限于 <a href="filesystem.configuration.html#ini.allow-url-include" class="link">allow_url_include</a></td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>允许读取</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>允许写入</td>
       <td>No</td>
      </tr>

      <tr>
       <td>允许追加</td>
       <td>No</td>
      </tr>

      <tr>
       <td>允许同时读写</td>
       <td>No</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.stat.html" class="function">stat()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.unlink.html" class="function">unlink()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.rename.html" class="function">rename()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.mkdir.html" class="function">mkdir()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.rmdir.html" class="function">rmdir()</a></span></td>
       <td>No</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>
 

 <div class="refsect1 examples" id="refsect1-wrappers.data-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-315">
   <p><strong>Example #1 打印 data:// 的内容</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;打印&nbsp;"I&nbsp;love&nbsp;PHP"<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'data://text/plain;base64,SSBsb3ZlIFBIUAo='</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>

  <div class="example" id="example-316">
   <p><strong>Example #2 获取媒体类型</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fp&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'data://text/plain;base64,'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$meta&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stream_get_meta_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;打印&nbsp;"text/plain"<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$meta</span><span style="color: #007700">[</span><span style="color: #DD0000">'mediatype'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="wrappers.compression.html">zlib://</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="wrappers.glob.html">glob://</a></div>
 <div class="up"><a href="wrappers.html">支持的协议和封装协议</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
